const express = require("express");
const requireAuth = require("../middleware/requireAuth");
const companyMaterialController = require("../controller/companyMaterialController");

const router = express.Router({ mergeParams: true }); //保留req.params来自父路由器的值。如果父项和子项的参数名称冲突，则子项的值优先

router
  .route("/")
  .post(requireAuth, companyMaterialController.createComMaterial)
  .delete(companyMaterialController.deleteSelectedComMaterial)
  .get(requireAuth, companyMaterialController.getAllComMaterial); //获取该公司下所有的材料

router
  .route("/:id")
  .delete(companyMaterialController.deleteComMaterial)
  .patch(companyMaterialController.updateComMaterial);

module.exports = router;
